import React,{Component,PropTypes} from 'react';
import {Card,Button} from 'antd';
import API, {} from 'lib/api';
import {redirect,backward} from 'lib/utils';
import './style.less';

var E = require('wangeditor');

export default class Init extends Component{
    constructor(props){
        super(props);

        this.state={
            crumb:[
                {href:"/",title:"首页"},
                {href:"/",title:"轮播图列表"},
                {href:"/",title:"添加轮播图"},
            ],
        }
    };


    componentWillMount(){

    };

    componentDidMount(){
        // 创建编辑器
        var editor = new E('#editor')
        editor.create();


        if(this.props.id){
        // 编辑状态,初始化内容

            // API.fetch("",{id:id},resp=>{
                editor.txt.html('<p>用 JS 设置的内容</p>')
            // });

        }

        document.getElementById('describe-btn1').addEventListener('click', function () {
            var html = editor.txt.html();
            console.log(html)
        });


    };

    componentWillUnmount(){


    };

    render(){
        return(
            <Card bordered={false} noHovering={true}>
                <div id="editor"></div>


                <Button id="describe-btn1" type="primary" >保存</Button>
            </Card>
        )
    }
}
